require(tidyverse)
require(ggrepel)
require(stargazer)
require(margins)
require(prediction)
require(lme4)
require(stringr)
require(AER)
require(broom)
require(sandwich)
require(skimr)
require(xtable)
require(survival)
require(lubridate)
repdata_main <- read_csv("ungc_rep_data.csv")
repdata_msci <- read_csv("msci_model_data.csv")
# dataset for multi-firm claims (claims with at least 4 named firms)
repdata_multi <- repdata_main %>%
group_by(Summary) %>%
filter(is.na(Summary) == F) %>%
mutate(firmsnamed = n()) %>%
filter(firmsnamed >= 4) %>%
ungroup()
figurex_data <- read_csv("diffusion_data.csv") %>%
slice(-1:-19)
basemod1lm <- lm(response_dummy ~ UNGC_Member,
data = repdata_main)
basemod1lm_r <-  coeftest(basemod1lm, vcovHC(basemod1lm, type = 'HC0', cluster = c('Company', 'Summary')))
basemod2lm <- lm(response_dummy ~ UNGC_Member + as.factor(naics2digit) + as.factor(Year),
data = repdata_main)
basemod2lm_r <- basemod2lm %>%
coeftest(vcovHC(basemod2lm, type = 'HC0', cluster = c('Company', 'Summary')))
basemod3lm <- lm(response_dummy ~ UNGC_Member + as.factor(Company) + as.factor(Year),
data = repdata_main)
basemod3lm_r <- basemod3lm %>%
coeftest(vcovHC(basemod3lm, type = 'HC0', cluster = c('Company', 'Summary')))
basemod4lm <- lm(response_dummy ~ UNGC_Member + prior_claims + log_total_assets +
v2csreprss_home + v2csreprss_host,
data = repdata_main)
basemod4lm_r <- basemod4lm %>%
coeftest(vcovHC(basemod4lm, type = 'HC0', cluster = c('Company', 'Summary')))
basemod5lm <- lm(response_dummy ~ UNGC_Member + prior_claims + log_total_assets +
v2csreprss_home + v2csreprss_host + as.factor(Year) + as.factor(naics2digit),
data = repdata_main)
basemod5lm_r <- basemod5lm %>%
coeftest(vcovHC(basemod5lm, type = 'HC0', cluster = c('Company', 'Summary')))
basemod6lm <- lm(response_dummy ~ UNGC_Member + prior_claims + log_total_assets +
v2csreprss_home + v2csreprss_host + as.factor(Year) + as.factor(Company),
data = repdata_main)
basemod6lm_r <- basemod6lm %>%
coeftest(vcovHC(basemod6lm, type = 'HC0', cluster = c('Company', 'Summary')))
# table 1 (to get obs + r squared stats)
stargazer(basemod1lm, basemod2lm, basemod3lm, basemod4lm,
basemod5lm, basemod6lm, omit = c("as.factor"))
multimod1lm <- lm(response_dummy ~ UNGC_Member,
data = repdata_multi)
multimod1lm_r <- multimod1lm %>%
coeftest(vcovHC(multimod1lm, type = 'HC0', cluster = c('Company', 'Summary')))
multimod2lm <- lm(response_dummy ~ UNGC_Member + as.factor(naics2digit) + as.factor(Year),
data = repdata_multi)
multimod2lm_r <- multimod2lm %>%
coeftest(vcovHC(multimod2lm, type = 'HC0', cluster = c('Company', 'Summary')))
multimod3lm <- lm(response_dummy ~ UNGC_Member + as.factor(Summary) + as.factor(Year) +
as.factor(naics2digit),
data = repdata_multi)
multimod3lm_r <- multimod3lm %>%
coeftest(vcovHC(multimod3lm, type = 'HC0', cluster = c('Company', 'Summary')))
multimod4lm <- lm(response_dummy ~ UNGC_Member + prior_claims + log_total_assets +
v2csreprss_home + v2csreprss_host, data = repdata_multi)
multimod4lm_r <- multimod4lm %>%
coeftest(vcovHC(multimod4lm, type = 'HC0', cluster = c('Company', 'Summary')))
multimod5lm <- lm(response_dummy ~ UNGC_Member + prior_claims + log_total_assets +
v2csreprss_home + v2csreprss_host + as.factor(Year) +
as.factor(naics2digit), data = repdata_multi)
multimod5lm_r <- multimod5lm %>%
coeftest(vcovHC(multimod5lm, type = 'HC0', cluster = c('Company', 'Summary')))
multimod6lm <- lm(response_dummy ~ UNGC_Member + prior_claims + log_total_assets +
v2csreprss_home + v2csreprss_host + as.factor(Year) +
as.factor(Summary) + as.factor(naics2digit),
data = repdata_multi)
multimod6lm_r <- multimod6lm %>%
coeftest(vcovHC(multimod6lm, type = 'HC0', cluster = c('Company', 'Summary')))
## table 3 (to get estimates w/ cluster robust SEs)
stargazer(multimod1lm_r, multimod2lm_r, multimod3lm_r, multimod4lm_r,
multimod5lm_r, multimod6lm_r, omit = c("as.factor"))
ivmod1 <- ivreg(response_dummy ~ UNGC_Member| sector_avg + country_avg, data = repdata_main)
ivmod2 <- ivreg(response_dummy ~ UNGC_Member + prior_claims + log_total_assets|
sector_avg + country_avg + prior_claims + log_total_assets, data = repdata_main)
ivmod3 <- ivreg(response_dummy ~ UNGC_Member + prior_claims + log_total_assets +
v2csreprss_home + v2csreprss_host |
sector_avg + country_avg + prior_claims + log_total_assets +
v2csreprss_home + v2csreprss_host, data = repdata_main)
ivmod4 <- ivreg(response_dummy ~ UNGC_Member + prior_claims + log_total_assets +
v2csreprss_home + v2csreprss_host + as.factor(Year) |
sector_avg + country_avg + prior_claims + log_total_assets +
v2csreprss_home + v2csreprss_host + as.factor(Year), data = repdata_main)
ivmod5 <- ivreg(response_dummy ~ UNGC_Member + prior_claims + log_total_assets +
v2csreprss_home + v2csreprss_host + as.factor(naics2digit) |
sector_avg + country_avg + prior_claims + log_total_assets +
v2csreprss_home + v2csreprss_host + as.factor(naics2digit), data = repdata_main)
ivmod6 <- ivreg(response_dummy ~ UNGC_Member + prior_claims + log_total_assets +
v2csreprss_home + v2csreprss_host + as.factor(Year) + as.factor(naics2digit)|
sector_avg + country_avg + prior_claims + log_total_assets +
v2csreprss_home + v2csreprss_host + as.factor(Year) + as.factor(naics2digit),
data = repdata_main)
stargazer(ivmod1, ivmod2, ivmod3, ivmod4, ivmod5, ivmod6,
omit = c("as.factor"))
ungc_membership <- read_csv("ungcmemberdata.csv")
ungc_membership <- ungc_membership %>%
mutate(joinyear = year(joineddate)) %>%
filter(firmtype == "Company" | firmtype == "Small or Medium-sized Enterprise" |
firmtype == "Business Association Local" | firmtype == "Business Association Global")
ungc_mem_plot <- ungc_membership %>%
group_by(joinyear) %>%
summarize(newjoins = n()) %>%
mutate(MemberFirms = cumsum(newjoins)) %>%
ggplot(aes(x = joinyear, y = MemberFirms)) +
geom_point() +
geom_line() +
labs(x = "Year", y = "Member Firms") +
theme_bw()
ungc_membership <- read_csv("ungcmemberdata.csv")
ungc_membership <- read_csv("ungcmemberdata.csv")
ungc_membership <- ungc_membership %>%
mutate(joinyear = year(joineddate)) %>%
filter(firmtype == "Company" | firmtype == "Small or Medium-sized Enterprise" |
firmtype == "Business Association Local" | firmtype == "Business Association Global")
ungc_mem_plot <- ungc_membership %>%
group_by(joinyear) %>%
summarize(newjoins = n()) %>%
mutate(MemberFirms = cumsum(newjoins)) %>%
ggplot(aes(x = joinyear, y = MemberFirms)) +
geom_point() +
geom_line() +
labs(x = "Year", y = "Member Firms") +
theme_bw()
ungc_mem_plot
ungc_by_sector <- repdata_main %>%
filter(is.na(naics_name) == F) %>%
group_by(naics_name) %>%
summarize(n = n(), ungc = mean(UNGC_Member, na.rm = T)) %>%
ggplot(aes(x = fct_reorder(as.factor(naics_name), ungc, .desc = T),
y = ungc, fill = n)) +
geom_bar(stat = "identity") +
scale_fill_gradient(low = "grey", high = "black") +
geom_hline(yintercept = .5, linetype = "dashed", alpha = .8) +
coord_flip() +
labs(x = "", y = "Proportion UNGC Members", fill = "# of observations") +
theme_bw()
ungc_by_sector
# get full-sample summary stats
desc_stats_overall <- repdata_main %>%
skim() %>%
slice(-1:-5, -14:-16) %>%
select(Variable = skim_variable, Missing = n_missing,
Mean = numeric.mean, SD = numeric.sd, Min = numeric.p0,
Max = numeric.p100) %>%
xtable()
print.xtable(desc_stats_overall, include.rownames = F)
desc_stats_ungc <- repdata_main %>%
filter(UNGC_Member == 1) %>%
skim() %>%
select(Variable = skim_variable, Missing = n_missing,
Mean = numeric.mean, SD = numeric.sd) %>%
slice(-1:-6, -8, -9, -14:-16)
desc_stats_nonungc <- repdata_main %>%
filter(UNGC_Member == 0) %>%
skim() %>%
select(Variable = skim_variable, Missing = n_missing,
Mean = numeric.mean, SD = numeric.sd) %>%
slice(-1:-6, -8, -9, -14:-16)
desc_stats <- desc_stats_ungc %>%
bind_cols(desc_stats_nonungc) %>%
select(-Variable...5) %>%
mutate(Diff = Mean...3 - Mean...7) %>%
xtable()
print.xtable(desc_stats, include.rownames = F)
figurex_data %>%
group_by(Country) %>%
summarize(n = n()/19) %>%
arrange(desc(n)) %>%
slice(1:12)
membership_by_country_data <- figurex_data %>%
filter(Country %in% c("United States", "Japan", "China", "United Kingdom",
"France", "South Korea", "Hong Kong", "India",
"Canada", "Germany", "Switzerland", "Taiwan")) %>%
group_by(Country, Year) %>%
summarize(members = sum(ungc_member),
prop_members = sum(ungc_member)/n())
membership_by_country_plot <- membership_by_country_data %>%
ggplot(aes(x = Year, y = prop_members, group = Country,
label = Country)) +
geom_line() +
facet_wrap(vars(Country)) +
labs(x = "", y = "Proportion UNGC Members") +
theme_bw()
membership_by_country_plot
meanclaims <- repdata_main %>% group_by(Company) %>% summarize(n = n())
mean(meanclaims$n)
repdata_main %>%
filter(is.na(naics_name) == F) %>%
group_by(naics_name) %>%
summarize(n = n(), ungc = mean(UNGC_Member, na.rm = T)) %>%
filter(ungc == 0) %>%
select(n) %>%
sum()
repdata_main %>%
filter(is.na(naics_name) == F) %>%
group_by(naics_name) %>%
summarize(n = n(), ungc = mean(UNGC_Member, na.rm = T)) %>%
filter(ungc >= .4 & ungc <= .6) %>%
select(n) %>%
sum()
